﻿@model mvcForum.Web.ViewModels.TopicViewModel
@using mvcForum.Core;
@using mvcForum.Web.Extensions;
@using mvcForum.Web.Helpers;
@{
	ViewBag.Title = ForumHelper.GetString("Topic.Title", new { Title = Model.Title });

	Layout = Url.GetThemeBaseUrl() + "areas/forum/views/shared/forumlayout.cshtml";
}
	<!-- Views/Moderate/Topic.aspx -->
	@Html.Partial("Breadcrumb", Model.Path)

	<span class="pull-right muted">@ForumHelper.GetString("CurrentTime", new object[] { DateTime.UtcNow })</span>

	<h2>@Model.Title</h2>

	<table class="table posts">
		<tbody>
@foreach (var message in Model.Posts) {
			<tr>
				<td>@Html.Partial("MessagePosterPartial", message)</td>
				<td>
					<div class="row">
						<div class="col-md-9">
							@if (message.Position == 0) {
								<h3>
								@if (message.Flag == PostFlag.Deleted) {
									@ForumHelper.GetString("Moderate.Deleted")
		}
		else if (message.Flag == PostFlag.Quarantined) {
									@ForumHelper.GetString("Moderate.Quarantined")
		}
								@message.Subject</h3>
	   }
	   else {
								<h4>
								@if (message.Flag == PostFlag.Deleted) {
									@ForumHelper.GetString("Moderate.Deleted")
		}
		else if (message.Flag == PostFlag.Quarantined) {
									@ForumHelper.GetString("Moderate.Quarantined")
		}
								@message.Subject</h4>
	   }
						</div>
						<div class="col-md-3">
							<p class="text-right muted">@message.Posted.ToLocalDateTime().ToString("F")</p>
						</div>
					</div>
					<hr />
					<div class="row">
						<div class="col-md-12">
							@if (message.Flag == PostFlag.Deleted) {
								@ForumHelper.GetString("Moderate.DeleteReason", new { Reason = message.DeleteReason })
	   }
	   else {
								@ForumHelper.ParseContent(message.Body)
	   }
						</div>
					</div>
					<hr />
					<div class="row">
						<div class="col-md-6 muted">
		@if (message.LastEdited.HasValue) {
							@ForumHelper.GetString("ViewMessage.Edited", new { Editor = (message.ModeratorChanged ? ForumHelper.GetString("Moderator") : message.PrettyName), Timestamp = message.LastEdited.Value })
		}
						</div>
						<div class="col-md-6">
							<ul class="list-inline pull-right">
		@if (message.Position != 0 && message.CanDelete && message.Flag != PostFlag.Deleted) {
								<li><a class="btn btn-success btn-xs" title="@(ForumHelper.GetString("ViewMessage.Delete"))" href="@Url.Action("delete", "message", new RouteValueDictionary { { "id", message.Id } })">@ForumHelper.GetString("ViewMessage.Delete")</a></li>
		}
		@if (message.CanDelete && message.Flag == PostFlag.Deleted) {
								<li><a class="btn btn-success btn-xs" title="@(ForumHelper.GetString("ViewMessage.Undelete"))" href="@Url.Action("undelete", "message", new RouteValueDictionary { { "id", message.Id } })">@ForumHelper.GetString("ViewMessage.Undelete")</a></li>
		}
		@if (message.CanEdit || message.IsModerator) {
								<li><a class="btn btn-success btn-xs" title="@(ForumHelper.GetString("ViewMessage.Moderate"))" href="@Url.Action("moderate", (message.Position == 0 ? "topic" : "message"), new RouteValueDictionary { { "id", (message.Position == 0 ? message.TopicId : message.Id) } })">@ForumHelper.GetString("ViewMessage.Moderate")</a></li>
		}
							</ul>
						</div>
					</div>
				</td>
			</tr>
}
		</tbody>
	</table>
@if (ForumHelper.Debug) {
<!-- For Selenium Test -->
<div id="forum_topic_index" style="display: none;"></div>
}